/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 最终版学生成绩管理系统;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class LookAllStudents extends IndexOrManage implements ActionListener{

	
	
public LookAllStudents(){
		
		super();
		//注册监听
		b1.addActionListener(this);
		b2.addActionListener(this);
		b3.addActionListener(this);
		
		pack();
		setVisible(true);
	}
public void actionPerformed(ActionEvent e) {
	// TODO 自动生成的方法存根
	if(e.getActionCommand()=="显示"){
		b1.setEnabled(false);
		try{
			Connection con=DataBaseCreate.getConnection();
			Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
			ResultSet rs=sql.executeQuery("select * from student");
			text.append("全体学生信息:\r\n");
			text.append("学号                姓名                生日                专业                         年级                班别                语文                        英语                        数学                        总分\r\n");
			while(rs.next()){
				text.append(rs.getString("Num")+"           "+rs.getString("Name")+"           "+rs.getString("Birth")+"           "+rs.getString("Major")
						+"              "+rs.getString("Grade")+"                      "+rs.getString("Class")+
						"                      "+rs.getFloat("Chinese")+"                      "+rs.getFloat("English")
						+"                      "+rs.getFloat("Maths")+"                      "+rs.getFloat("Total")+"\r\n");
			}
			
			
		}catch(java.lang.ClassNotFoundException err){
			JOptionPane.showMessageDialog(null, err.getMessage(), "ClassNotFoundException:",
					JOptionPane.INFORMATION_MESSAGE);
			}catch (SQLException ex){
				JOptionPane.showMessageDialog(null, ex.getMessage(), "SQLException: ", JOptionPane.INFORMATION_MESSAGE);
			}
	}
	else if(e.getActionCommand()=="取消"){
		setVisible(false);
	}
	else if(e.getActionCommand()=="保存"){
		TxtSave save=new TxtSave(text.getText(),"全体");
	}
}


}

